import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routers'
import store from '@/store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'


// 多次点击跳转同一个路由是不被允许的
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)
const router = new VueRouter({
    routes
})



router.beforeEach((to, from, next) => {
    // //开启NProgress进度条
    NProgress.configure({ showSpinner: false });
    NProgress.start()

    next()
})

router.afterEach(to => {
    NProgress.done() //结束NProgress进度条
})

export default router
